#include"context.h"
#include"concrete_strategy.h"
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) { if(p){delete(p); (p)=NULL;} }
#endif
int main()
{
    // 策略之间可以相互替换
    IStrategy *bike = new BikeStrategy();
    IStrategy *car = new CarStrategy();
    IStrategy *train = new TrainStrategy();

    Context *context = new Context(bike);


    context->Travel();
    context->SetStrategy(car);
    context->Travel();
    context->SetStrategy(bike);
    context->Travel();

    SAFE_DELETE(bike);
    SAFE_DELETE(car);
    SAFE_DELETE(train);

    SAFE_DELETE(context);


    getchar();


    return 0;
}
